Skip to content

fix(tui): simplify sidebar toggle to respect terminal width#36414

Open
JohnXu22786 wants to merge 2 commits into
anomalyco:devfrom
JohnXu22786:sidebar-toggle-fix
Open

fix(tui): simplify sidebar toggle to respect terminal width#36414
JohnXu22786 wants to merge 2 commits into
anomalyco:devfrom
JohnXu22786:sidebar-toggle-fix

Conversation

@JohnXu22786

@JohnXu22786 JohnXu22786 commented Jul 11, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #36417

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The sidebar visibility logic had two overlapping state variables:

  1. sidebar (persistent KV): "auto" or "hide"
  2. sidebarOpen (local signal): temporary override

When toggling the sidebar ON via the command palette, sidebarOpen was set to true, which overrode the terminal width check (wide()) and forced the sidebar visible regardless of screen width. This caused the sidebar to show in narrow windowed mode where it should have remained hidden, blocking content until TUI restart.

This PR removes the sidebarOpen signal entirely. Sidebar visibility is now determined solely by the persistent mode:

  • "auto": visible only when terminal width > 120 columns
  • "hide": never visible

The toggle command simply switches between "auto" and "hide" modes. Also removed the now-dead !wide() rendering branch (the overlay variant was only reachable when sidebarOpen was true).

How did you verify your code works?

  • Added 7 unit tests in packages/tui/test/session/sidebar.test.tsx covering the core visibility logic, toggle behavior, and the regression scenario
  • All 197 existing tests continue to pass (1 pre-existing Windows path failure unrelated)
  • Manual reasoning: the sidebarVisible memo now correctly depends only on sidebar() and wide(), so toggling on a narrow terminal won't force-show the sidebar

Screenshots / recordings

N/A - terminal UI change, not visual.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

The sidebar visibility logic had two state variables: a persistent
`sidebar` mode ("auto" / "hide") and a local `sidebarOpen` signal.
When toggling the sidebar on via the command palette, `sidebarOpen`
was set to `true`, which overrode the terminal width check and
forced the sidebar to show even on narrow (windowed) terminals.

Remove `sidebarOpen` entirely. Sidebar visibility is now determined
solely by the persistent mode: visible only when mode is "auto"
AND the terminal is wide enough (>120 columns). The toggle command
simply switches between "auto" and "hide" modes.

Also remove the dead `!wide()` rendering branch inside the sidebar
visibility guard, since `sidebarVisible()` now requires `wide()`
to be true.

Fixes the bug where enabling sidebar in windowed mode would
force-show it on the right side, blocking content, until restart.
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Jul 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@JohnXu22786 JohnXu22786 marked this pull request as draft July 11, 2026 13:21
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jul 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@JohnXu22786 JohnXu22786 marked this pull request as ready for review July 11, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sidebar toggle forces visible in windowed mode ignoring terminal width

1 participant